/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 涛
 * Date: 2023-09-29
 * Time: 13:29
 */
class Question {
    public int removeDuplicates(int[] nums) {
        int a = 1;
        //遍历，上下两位数不同时，按顺序给数组赋值
        for (int i = 0; i < nums.length -1; i++) {
            if(nums[i]!=nums[i+1]){
                nums[a] = nums[i+1];
                a++;
            }
        }
        return a;
    }
}
public class Test2 {
    public static void main(String[] args) {
        int[] nums = {1,1,2};
        Question  question = new Question();
        question.removeDuplicates(nums);

    }
}
